<!doctype html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
      div {
        width: 100px;
        height: 100px;
      }
    </style>
  </head>
  <body>
    <div id="app">
      <div :style="style"></div>
      <div :style="style1"></div>
      <div :style="style2"></div>
      <div :style="changs(1)"></div>
      <button @click="changColor">改变颜色</button>
      <div :style="`background-image: url($i{mgSrc});`"></div>
      <div :style="`background-image: url(${imgSrc});`"></div>
    </div>
  </body>
  <script>
    const vm = new Vue({
      el: " #app",
      data: {
        style: "background-color:red",
        style1: { backgroundColor: "yellow" },
        style2: [
          {
            backgroundColor: "green",
          },
        ],
        imgSrc: "day01/下载.jpg",
      },
      methods: {
        changColor() {
          this.style2[0].backgroundColor = "blue";
        },
        changs(n) {
          return n == 1
            ? {
                backgroundColor: "pink",
              }
            : {
                backgroundColor: "gray",
              };
        },
      },
    });
  </script>
</html>
